﻿using CoreShop.App.Properties;
using Sunny.UI;
using System;
using System.Drawing;
using System.Windows.Forms;

namespace CoreShop.App
{
    public partial class UIPrinterItem : UIUserControl
    {
        public UIPrinterItem()
        {
            InitializeComponent();
        }

        private void UIPrinterItem_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.FillRoundRectangle(Color.White, new Rectangle(1, 5, 413, 243), 9);
            if (ShowLogo)
            {
                e.Graphics.DrawImage(Resources._111, new Rectangle(Width - 91, 0, 91, 91));
            }
        }

        public bool ShowLogo { get; set; }

        public string PrinterName { get => lblName.Text; set => lblName.Text = value; }

        public string Desc1 { get => uiLabel1.Text; set => uiLabel1.Text = value; }

        public string Desc2 { get => uiLabel2.Text; set => uiLabel2.Text = value; }

        public Image Image { get => pictureBox1.Image; set => pictureBox1.Image = value; }

        public string IP { get => uiLabel3.Text; set => uiLabel3.Text = value; }

        private void btn_Click(object sender, System.EventArgs e)
        {
            ClickOperation?.Invoke(this, e);
        }

        public event EventHandler ClickOperation;

        public event EventHandler PrintTestPage;

        private void uiButton1_Click(object sender, System.EventArgs e)
        {
            PrintTestPage?.Invoke(this, e);
        }

        private bool linked = false;
        public bool Linked
        {
            get => linked;
            set
            {
                linked = value;
                if (linked)
                {
                    uiPanel1.Text = "已连接";
                    uiPanel1.FillColor = uiPanel1.RectColor = UIColor.Green;
                }
                else
                {
                    uiPanel1.Text = "已断开";
                    uiPanel1.FillColor = uiPanel1.RectColor = UIColor.Red;
                }
            }
        }

        public event EventHandler EditNetwork;
        private void uiPanel2_Click(object sender, EventArgs e)
        {
            EditNetwork?.Invoke(this, e);
        }

        public bool ShowEditNetwork { get => uiPanel2.Visible; set => uiPanel2.Visible = value; }
    }
}
